package game;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

import org.apache.jasper.tagplugins.jstl.core.Url;

import jgame.JGPoint;
import jgame.platform.JGEngine;

public class Main extends JGEngine {

	private static Main main;
	private URL url;
	private URLConnection servletConnection;
	private String str;

	public Main(JGPoint size) {
		initEngine(size.x, size.y);
	}

	public Main() {
		initEngineApplet();
	}

	public static void main(String[] args) {
		main = new Main(new JGPoint(0, 0));
	}

	@Override
	public void initCanvas() {
		setCanvasSettings(65, 48, 16, 16, null, null, null);
	}

	@Override
	public void initGame() {
		// defineMedia("space_run.tbl");
		try {
			url = new URL(getCodeBase(), "PlayerAvatar");
			servletConnection = url.openConnection();
			servletConnection.setDoInput(true);
			servletConnection.setDoOutput(true);
			servletConnection.setUseCaches(false);
			servletConnection.setDefaultUseCaches(false);
			servletConnection.setRequestProperty("Content-Type", "text/plain");
			InputStreamReader input = new InputStreamReader(
					servletConnection.getInputStream());
			BufferedReader in = new BufferedReader(input);
			str = new String();
			str = in.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void doFrame() {
		moveObjects(null, 0);
	}

	public void paintFrame() {
		drawString("lalalal", 200, 200, -1);
	}

}
